package com.homework;

import java.util.Scanner;

public class demo06 {
    public static void main(String[] args) {
        //定义数组
        int[] arr = new int[]{11, 22, 33, 22, 11};
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入需要查询的数字");
        int num = sc.nextInt();
        //定义计数器，若结束循环计数器仍为零，即不存在，给出反馈
        int count = 0;
        int tp = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == num) {
                count++;
                tp = i;
            }
        }
        if (count == 0) {
            System.out.println("数组内并不存在元素：" + num);
        } else {
            System.out.println(num + "最后出现的角标位置是：" + tp);
        }
    }
}
